<?php

namespace App\Models\Station;

use App\Models\Image;
use App\Models\Station;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use App\Events\Station\Report\CreatedEvent;

/**
 * 报岗数据模型
 *
 * Date: 01/05/2018
 * @author George
 * @package App\Models
 */
class Report extends Model
{
	/**
	 * 定义不可填充字段
	 *
	 * @var array
	 * Date: 30/04/2018
	 * @author George
	 */
    protected $guarded = ['id'];

	/**
	 * 定义模型时间
	 *
	 * @var array
	 * Date: 02/05/2018
	 * @author George
	 */
    protected $dispatchesEvents = [
    	'created' => CreatedEvent::class
	];

	/**
	 * 获取岗点信息
	 *
	 * Date: 11/05/2018
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
	 */
	public function station()
	{
		return $this->belongsTo(Station::class, 'station_id', 'id');
    }

	/**
	 * 获取报岗图片
	 *
	 * Date: 25/04/2018
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\MorphMany
	 */
	public function images()
	{
		return $this->morphMany(Image::class, 'imagetable');
	}

	/**
	 * 获取报岗用户信息
	 *
	 * Date: 2018/5/25
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
	 */
	public function user()
	{
		return $this->belongsTo(User::class, 'user_id', 'id');
	}
}
